import 'dart:collection';

import 'package:simulator/utils/common.dart';

enum CoroutineAction { reserved, yield, terminate, enter }

///携程
///
final class Coroutine extends LinkedListEntry<Coroutine> {
  final Future Function(dynamic args) entry;
  dynamic args;

  Coroutine(this.entry);

  String? _schedule;

  Coroutine.create(this.entry, [this.args]);

  static void schedule(Coroutine coroutine) {
    if (coroutine._schedule != null) {
      abort("Co-routine was already scheduled in ${coroutine._schedule}");
    }
  }
}
